home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
GRAPHICS
/
IMGLIB95
/
UMAIL.PA_
/
UMAIL.PA
Wrap
Text File
|
1996-03-31
|
8KB
|
286 lines
{
Written by Jan Dekkers and Kevin Adams (c) 1995, 1996. If you are a non
registered client, you may use or alter this demo only for evaluation
purposes.
Copyright by SkyLine Tools. All rights reserved.
Part of Imagelib VCL/DLL Library.
}
unit Umail;
{Includes settings to compile in either 16 or 32 bit}
{$I DEFILIB.INC}
interface
uses
{$IFDEF DEL32}
Windows,
{$ELSE}
WinTypes,
WinProcs,
{$ENDIF}
DLL95V1, {ImageLib Dll interface and misc. functions}
SysUtils,
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ExtCtrls,
DBCtrls,
MPlayer,
StdCtrls,
DB,
DBTables,
Gauges,
Mask,
Buttons,
Spin,
Tdmultim, Tdmultip; {PDBMultiMedia1, PDBMultiImage VCL component}
type
TMailOrderForm = class(TForm)
DataSource1: TDataSource;
Table1: TTable;
DBMultiImage1: TPDBMultiImage;
DBMultiMedia1: TPDBMultiMedia;
DBMemo1: TDBMemo;
DBMultiImage2: TPDBMultiImage;
AddMM: TBitBtn;
AddImage: TBitBtn;
AddMsg: TBitBtn;
BitBtn6: TBitBtn;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
Gauge1: TGauge;
Gauge2: TGauge;
OpenDialog1: TOpenDialog;
DBMediaPlayer1: TPDBMediaPlayer;
SpinButton1: TSpinButton;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure AddImageClick(Sender: TObject);
procedure AddMMClick(Sender: TObject);
procedure DataSource1DataChange(Sender: TObject; Field: TField);
procedure AddMsgClick(Sender: TObject);
procedure SpinButton1DownClick(Sender: TObject);
procedure SpinButton1UpClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
Procedure Trigger(Sender : TObject; Var Done : Boolean);
public
{ Public declarations }
end;
var
MailOrderForm: TMailOrderForm;
implementation
{$R *.DFM}
{---------------------------------------------------------------------}
{IMPORTANT}
{Changed in version 2.21 from a procedure to a function with cdecl.
To cancel return a 0 else return a 1}
Function MMCalledBack ( i : integer) : integer; cdecl; export;
{Callback function from the dll, CDECL and EXPORT ARE REQUIRED}
begin
if Application.Terminated then
{User wants to terminate the program. Pass a 0 to the dll}
Result:=0
else begin
{Process Progress bar}
if MailOrderForm <> Nil then
MailOrderForm.Gauge1.Progress:=i;
{Live in peace with others}
Application.ProcessMessages;
{tell the dll that everything is OK}
Result:=1;
end;
end;
{---------------------------------------------------------------------}
{IMPORTANT}
{Changed in version 2.21 from a procedure to a function with cdecl.
To cancel return a 0 else return a 1}
Function MICalledBack ( i : integer) : integer; cdecl; export;
{Callback function from the dll, CDECL and EXPORT ARE REQUIRED}
begin
if Application.Terminated then
{User wants to terminate the program. Pass a 0 to the dll}
Result:=0
else begin
{Process Progress bar}
if MailOrderForm <> Nil then
MailOrderForm.Gauge2.Progress:=i;
{Live in peace with others}
Application.ProcessMessages;
{tell the dll that everything is OK}
Result:=1;
end;
end;
{---------------------------------------------------------------------}
Procedure TMailOrderForm.Trigger(Sender : TObject; Var Done : Boolean);
begin
{IMPORTANT}
{This function is called when your app is idle. Subdivide the
trigger event to your TDBMultiMedia objects who may need one.
If no Message is active it will not take up significant time}
DBMultiMedia1.Trigger;
DBMultiImage1.Trigger;
DBMultiImage2.Trigger;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.FormCreate(Sender: TObject);
begin
{Register the callback Fuctions to the VCL}
TPDBMultiMediaCallBack:=MMCalledBack;
TPDBMultiImageCallBack:=MICalledBack;
If FileExists(ExtractFilePath(Application.ExeName)+'MAIL_ORD.DB') then begin
{if the table exists open it on creation}
Table1.DataBaseName:=ExtractFilePath(Application.ExeName);
Table1.TableName:='MAIL_ORD.DB';
Table1.Active:=True;
end;
{IMPORTANT}
{This is the moving engine for all the messages. Since an applcation
can have only one OnIdle Trigger, this trigger needs to be subdivided
by all your moving and animated objects. In this particular case the
function is called TRIGGER but you can name it as you want as long
you have a procedure named the same.}
Application.OnIdle:=Trigger;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.AddImageClick(Sender: TObject);
begin
OpenDialog1.filter:='All Images|*.png;*.jpg;*.bmp;*.gif;*.pcx|Png|*.png|Jpeg|*.jpg|BitMap|*.bmp|Gif|*.gif|Pcx|*.pcx';
{Execute the open dialog box}
if OpenDialog1.Execute then begin
Table1.Edit;
{Load the Multimedia into the Blob}
DBMultiImage2.LoadfromFile(OpenDialog1.FileName);
{Post that thing}
Table1.Post;
end;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.AddMMClick(Sender: TObject);
begin
{fill the OpenDialog filter with the MM extensions as found in the win.ini
(This means that the appropriate drivers are installed)}
OpenDialog1.filter:=GetMultiMediaExtensions;
{Execute the open dialog box}
if OpenDialog1.Execute then begin
Table1.Edit;
{Load the Multimedia into the Blob}
DBMultiMedia1.LoadfromFile(OpenDialog1.FileName);
{Post that thing}
Table1.Post;
end;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.DataSource1DataChange(Sender: TObject; Field: TField);
begin
{Set the Video display rectangle to the rectangle of the blob window}
DBMediaPlayer1.DisplayRect:=Rect(0,0,DBMultiMedia1.Width,DBMultiMedia1.Height);
{Set the Video display to the the display of the blob window}
DBMediaPlayer1.Display:=DBMultiMedia1;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.AddMsgClick(Sender: TObject);
begin
Table1.Edit;
{Create a New Message}
If DBMultiImage1.CreateMessage then
{Post or cancel that thing}
Table1.Post
else
Table1.Cancel;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.SpinButton1DownClick(Sender: TObject);
begin
if DBMultiImage1.MsgSpeed <10 then Inc(DBMultiImage1.MsgSpeed)
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.SpinButton1UpClick(Sender: TObject);
begin
if DBMultiImage1.MsgSpeed >0 then Dec(DBMultiImage1.MsgSpeed)
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.BitBtn1Click(Sender: TObject);
begin
{Place the Database in Edit mode}
Table1.Edit;
{Create a New Credit Message}
If DBMultiMedia1.CreateCreditMessage then
{Post or cancel that thing}
Table1.Post
else
Table1.Cancel;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.CheckBox1Click(Sender: TObject);
begin
DBMultiImage2.Stretch:=CheckBox1.Checked;
end;
{---------------------------------------------------------------------}
procedure TMailOrderForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Application.OnIdle:=Nil;
{UNRegister the callback Fuctions to the VCL}
TPDBMultiMediaCallBack:=Nil;
TPDBMultiImageCallBack:=Nil;
MailOrderForm:=Nil;
Action:=caFree;
end;
end.